//package com.yunhe.authority.controller.authority;
//
//import com.yunhe.authority.service.authority.HomePageService;
//import com.yunhe.authority.domain.authority.HomePage;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.ResultObject;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
///**
// * 首页Controller
// * @author liuronglei
// */
//@Api(value = "homePage",description = "首页维护", tags = {"Authority_HomePage"})
//@RestController
//@RequestMapping("/homePages")
//public class HomePageController {
//    @Autowired
//    private HomePageService homePageService;
//
//    /**
//     * 新增首页
//     * @param homePage 首页对象
//     */
//    @ApiOperation("新增首页")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@RequestBody HomePage homePage)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        HomePage newHomePage = homePageService.createHomePage(homePage);
//        return new ResponseEntity<>(new ResultObject<>(newHomePage), HttpStatus.OK);
//    }
//
//    /**
//     * 根据首页ID删除首页
//     * @param id 首页ID
//     */
//    @ApiOperation("根据首页ID删除首页")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "首页ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(@PathVariable("id") Long id) {
//        homePageService.deleteHomePage(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新首页（更新全部字段）
//     * @param id 首页ID
//     * @param homePage 首页对象
//     */
//    @ApiOperation("更新首页（更新全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "首页ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(@PathVariable("id") Long id,
//                                            @RequestBody HomePage homePage)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        homePage.setId(id);
//        HomePage newHomePage = homePageService.updateHomePage(homePage);
//        return new ResponseEntity<>(new ResultObject<>(newHomePage), HttpStatus.OK);
//    }
//
//    /**
//     * 更新首页（更新指定字段）
//     * @param id 首页ID
//     * @param name 首页名
//     * @param title 首页标题
//     * @param url 首页Url
//     * @param activity 是否可用
//     */
//    @ApiOperation("更新首页（更新指定字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "首页ID", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "name", value = "首页名", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "首页标题", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "url", value = "首页Url", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "Boolean", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(@PathVariable("id") Long id,
//                                              @RequestParam("name") Optional<String> name,
//                                              @RequestParam("title") Optional<String> title,
//                                              @RequestParam("url") Optional<String> url,
//                                              @RequestParam("activity") Optional<Boolean> activity)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        HomePage newHomePage = homePageService.updateHomePage(id, name.orElse(null), title.orElse(null),
//                url.orElse(null), activity.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newHomePage), HttpStatus.OK);
//    }
//
//    /**
//     * 根据首页ID获得首页
//     * @param id 首页ID
//     */
//    @ApiOperation("根据首页ID获得首页")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "首页ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(@PathVariable("id") Long id) {
//        HomePage homePage = homePageService.findByHomePageId(id);
//        return new ResponseEntity<>(new ResultObject<>(homePage), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得首页列表
//     */
//    @ApiOperation("根据条件获得首页列表")
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search() {
//        Iterable<HomePage> results = homePageService.findHomePages();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//}